package com.chencs.app.special.service;

import com.chencs.app.special.mapper.AppSpecialMapper;
import com.chencs.vo.biz.product.ProductModel;
import com.chencs.vo.biz.special.SpecialModel;
import com.chencs.vo.net.request.RequestBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by fangzehua on 2017/7/12.
 */
@Service
@Transactional
public class AppSpecialService {

    @Autowired
    private AppSpecialMapper appSpecialMapper;

    public List<SpecialModel> getSpecialList(RequestBase request){

        Map<String,Object> map = new HashMap<>();
        map.put("pageno",request.getPageNo()*request.getPageSize());
        map.put("pagesize",request.getPageSize());
        List<SpecialModel> models = appSpecialMapper.getSpecialList(map);

//        for(SpecialModel model:models){
//            if (model.getType().equals("0")){
//                model.setList(appSpecialMapper.findSpecialProBySid(model.getId()));
//            }
//
//        }
        return models;
    }


    public SpecialModel findSpecial(String id){

        return  appSpecialMapper.findSpecial(id);
    }


    public List<ProductModel> findSpecialProBySid(String sid){

        return appSpecialMapper.findSpecialProBySid(sid);
    }
}
